package com.leoman.dao;

import com.leoman.entity.UserTag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * UserTagDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:47.
 */
public interface UserTagDao extends JpaRepository<UserTag, Integer>, JpaSpecificationExecutor<UserTag> {

    @Query("select a from UserTag a where a.user.id = ?1 order by a.isDefault desc")
    List<UserTag> findListByUserId(Integer userId);

    @Query("select a from UserTag a where a.user.id = ?1 and a.content = ?2")
    UserTag findOneByParams(Integer userId, String content);
}